import allure
from selenium.webdriver.common.by import By

from base.base_action import BaseAction
import time
import allure
import pytest
from base.base_driver import InitDriver


class PeapleList(BaseAction):

    name_btn = By.XPATH,"//span[@class='t-name']"
    all_survey = By.XPATH,"//div[@class='cell-btns']//span"
    be_yes = By.XPATH,"//div[@class='el-message-box__wrapper']//button//span[contains(text(),'确定')]"
    # 重新分配
    update = By.XPATH, "//tbody//span[contains(text(),'重新分配')]"
    # 连续未测量
    untest_day = By.XPATH,"//tr//td[10]//div"

    # 点击居民管理
    def click_btn_peaple_manage(self):
        return self.click_span_text("居民管理")

    # 点击居民列表
    def click_btn_peaple_list(self):
        return self.click_li_text("居民列表")

    # 按姓名搜索
    def input_peaple_name(self,text):
        return self.input_placeholder_text("按姓名",text)

    # 点击查询
    def click_btn_search(self):
        return self.click_span_contains_text("查询")

    # 点击全部测量
    @allure.step(title='点击全部测量')
    def click_btn_all_survey(self):
        return self.click(self.all_survey)

    # 点击健康咨询
    def click_btn_health_refer(self):
        return self.click_span_text("健康咨询")

    # 点击电子病历
    def click_btn_case_history(self):
        return self.click_span_text("电子病历")

    #获取第一个居民姓名
    @allure.step(title='获取第一个居民姓名')
    def get_text_peaple_list_name(self):
        return self.get_text(self.name_btn)


    @allure.step(title='点击确定')
    def click_be_yes(self):
        return self.click_mouse(self.be_yes)

    @allure.step(title='点击重新分配')
    def click_update(self):
        return self.click(self.update)

    @allure.step(title='获取未测量天数')
    def get_text_untest_day(self):
        return self.get_text(self.untest_day)